From 8c68c97c03c15a113c5a47905297603525bcb2ff Mon Sep 17 00:00:00 2001 From: Jyrki Gadinger Date: Thu, 15 May 2025 16:11:38 +0200 Subject: [PATCH] feat(mac-crafter): retry code-signing attempts This step sometimes fails with an error such as: "A timestamp was expected but was not found.". Any code-signing errors will result in the notarisation step to fail. Apparently this might be due to intermittent network issues. Let's just retry codesigning a couple of times in the case it fails ... See also: https://developer.apple.com/documentation/security/resolving-common-notarization-issues#Include-a-secure-timestamp Signed-off-by: Jyrki Gadinger --- admin/osx/mac-crafter/Sources/Utils/Codesign.swift | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift index 1f43d3e49..927133133 100644 --- a/admin/osx/mac-crafter/Sources/Utils/Codesign.swift +++ b/admin/osx/mac-crafter/Sources/Utils/Codesign.swift @@ -55,9 +55,17 @@ func isExecutable(_ path: String) throws -> Bool { func codesign(identity: String, path: String, options: String = defaultCodesignOptions) throws { print("Code-signing \(path)...") let command = "codesign -s \"\(identity)\" \(options) \"\(path)\"" - guard shell(command) == 0 else { - throw CodeSigningError.failedToCodeSign("Failed to code-sign \(path).") + for _ in 1...5 { + guard shell(command) == 0 else { + print("Code-signing failed, retrying ...") + continue + } + + // code signing was successful + return } + + throw CodeSigningError.failedToCodeSign("Failed to code-sign \(path).") } func recursivelyCodesign( -- 2.30.2